package com.kk.xhr.model.assembler;

import com.kk.xhr.common.pojo.ApplyStatusEnum;
import com.kk.xhr.common.pojo.ComplementSignTypeEnum;
import com.kk.xhr.common.pojo.WorkCompensateTypeEnum;
import com.kk.xhr.common.pojo.WorkOvertimeTypeEnum;
import com.kk.xhr.model.dto.ComplementSignDTO;
import com.kk.xhr.model.dto.WorkOvertimeDTO;
import com.kk.xhr.model.entity.ComplementSign;
import com.kk.xhr.model.entity.WorkOvertime;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * 补签数据转换工具类
 *
 * @author kkmystery
 * @version 1.0 2021/3/1
 * @since 1.0.0
 */
@Mapper(componentModel = "spring")
public interface ComplementSignStructKit {

    ComplementSignStructKit INSTANCE = Mappers.getMapper(ComplementSignStructKit.class);

    /**
     * dto -> entity
     *
     * @param dto dto
     * @return entity
     */
    ComplementSign toEntity(ComplementSignDTO dto);

    /**
     * entity -> dto
     *
     * @param entity entity
     * @return dto
     */
    ComplementSignDTO toDto(ComplementSign entity);

    default ApplyStatusEnum applyStatusConvertor(Byte status) {
        if (null == status) {
            return null;
        }
        return ApplyStatusEnum.from(status);
    }

    default Byte applyStatusConvertor(ApplyStatusEnum status) {
        if (null == status) {
            return null;
        }
        return status.getValue();
    }

    default ComplementSignTypeEnum typeConvertor(Byte status) {
        if (null == status) {
            return null;
        }
        return ComplementSignTypeEnum.from(status);
    }

    default Byte typeConvertor(ComplementSignTypeEnum status) {
        if (null == status) {
            return null;
        }
        return status.getValue();
    }
}
